package view.backing;

import java.util.List;

import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.input.RichSelectManyChoice;
import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;


public class LOVValueDemoBean
{
  private RichSelectOneChoice normalLOV;
  private RichInputText valueDisplay;
  private RichSelectOneChoice textLOVSingle;
  private RichSelectOneChoice textIDLOV;
  private RichSelectManyChoice textMultiLOV;
  private RichSelectManyChoice textIDMultiLOV;

  public LOVValueDemoBean()
  {
  }

  public String getValueNormal()
  {
    String value = String.valueOf(getNormalLOV().getValue());
    getValueDisplay().setValue(value);
    return null;
  }

  public void setNormalLOV(RichSelectOneChoice normalLOV)
  {
    this.normalLOV = normalLOV;
  }

  public RichSelectOneChoice getNormalLOV()
  {
    return normalLOV;
  }

  public void setValueDisplay(RichInputText normalValueDisplay)
  {
    this.valueDisplay = normalValueDisplay;
  }

  public RichInputText getValueDisplay()
  {
    return valueDisplay;
  }

  public String getTextValueSingle()
  {
    String value = String.valueOf(getTextLOVSingle().getValue());
    getValueDisplay().setValue(value);
    return null;
  }

  public void setTextLOVSingle(RichSelectOneChoice textLOVSingle)
  {
    this.textLOVSingle = textLOVSingle;
  }

  public RichSelectOneChoice getTextLOVSingle()
  {
    return textLOVSingle;
  }

  public void setTextIDLOV(RichSelectOneChoice textIDLOV)
  {
    this.textIDLOV = textIDLOV;
  }

  public RichSelectOneChoice getTextIDLOV()
  {
    return textIDLOV;
  }

  public String getTextIDValue()
  {
    String value = String.valueOf(getTextIDLOV().getValue());
    getValueDisplay().setValue(value);
    return null;
  }

  public void setTextMultiLOV(RichSelectManyChoice textMultiLOV)
  {
    this.textMultiLOV = textMultiLOV;
  }

  public RichSelectManyChoice getTextMultiLOV()
  {
    return textMultiLOV;
  }

  public String getTextValueMulti()
  {
    List<String> selected = (List<String>) getTextMultiLOV().getValue();
    String csvValue = "";
    for (String s: selected)
    {
      csvValue = csvValue + s + ",";
    }
    getValueDisplay().setValue(csvValue);
    return null;
  }

  public void setTextIDMultiLOV(RichSelectManyChoice textIDMultiLOV)
  {
    this.textIDMultiLOV = textIDMultiLOV;
  }

  public RichSelectManyChoice getTextIDMultiLOV()
  {
    return textIDMultiLOV;
  }

  public String getAllIDsSelected()
  {
    List<oracle.jbo.domain.Number> selected =
      (List<oracle.jbo.domain.Number>) getTextIDMultiLOV().getValue();
    String csvValue = "";
    for (oracle.jbo.domain.Number s: selected)
    {
      csvValue = csvValue + s.intValue() + ",";
    }
    getValueDisplay().setValue(csvValue);
    return null;
  }
}
